﻿package mortal.common.global
{
    import com.gengine.core.*;
    import com.gengine.debug.*;
    import com.gengine.global.*;
    import com.gengine.utils.*;
    import extend.php.*;
    import flash.display.*;

    public class ParamsConst extends ClassProxy
    {
        private var _isInit:Boolean = false;
        public var platformCode:String = "";
        public var platformCodeInt:int;
        public var platformUserName:String;
        public var username:String;
        public var player_id:int;
        public var userId:int;
        public var server:String;
        public var time:Object;
        public var issm:int;
        public var isAdult:int;
        public var totalOnlineTime:Number;
        public var flag:String;
        public var defaultCamp:int;
        public var defaultSex:int;
        public var roleName:String;
        public var guest:int;
        public var newUser:int = 0;
        public var version:String = "1.0.0.0";
        public var flashVersion:String = "1.0.0.0";
        public var loginIP:String = "192.168.10.91:9500";
        public var gameIP:String;
        public var mainPath:String;
        public var configUrl:String;
        public var resTime:String = "";
        public var createRoleUrl:String = "CreateRole.swf";
        public var gameUrl:String = "MainGame.swf";
        public var createRoleVersion:String = "";
        public var password:String;
        public var isConnectionServer:Boolean = true;
        public var dothingUrl:String;
        public var phpID:int;
        public var payUrl:String;
        public var yyZiZuanUrl:String = "http://show.vip.yy.com/pay/index.html?src=fbdl";
        public var actimUrl:String;
        public var bbsUrl:String;
        public var proctecUrl:String;
        public var xskUrl:String = "http://frxz2.4399.com";
        public var phoneUrl:String;
        public var title:String;
        public var gmInfo:String;
        public var randomNameUrl:String;
        public var loginGiftUrl:String;
        public var sDocc:int;
        public var fastUrl:String = "";
        public var issmType:int = 0;
        public var languageType:String;
        public var proxyType:String;
        public var isShowFavorites:int = 1;
        public var favoritesUrl:String = "";
        public var downLoadLanderUrl:String = "";
        public var cacheSetUrl:String;
        public var gameName:String = null;
        public var gameMsgURL:String;
        public var preLoadPageBg:String;
        public var preLoadPageBgCreateRole:String;
        public var preLoaderVersion:String = "";
        public var forgameLogoVersion:String = "";
        public var preloaders:String = "";
        public var libraryUrls:String = "";
        public var isLocalCache:Boolean = false;
        public var localurl:String;
        public var chatBaseLevel:int = 20;
        public var chatLimitLevel:int = 50;
        public var chatPrivateLevel:int = 14;
        public var gameTipsPath:String = "assets/config/gametips.xml";
        public var quickRegisterUrl:String = "http://frmmo1.my4399.com/f2_game/create_plant_user.php";
        public var updateUrl:String = "update_notice/";
        public var gmUrl:String;
        public var gmJsFun:String = "";
        public var gmHelpUrl:String;
        public var vipHelpUrl:String;
        public var timerTestType:int = 0;
        public var chatNumLimit:int = 3;
        public var vipHelpNeedGold:int = 50000;
        public var whoPlayGameUrl:String;
        public var friendPlayGameUrl:String;
        public var attentionUrl:String;
        public var isNewServer:int;
        public var currentCity:String = "";
        public var isUIByLevel:Boolean = false;
        public var isAutoEnterGame:Boolean = true;
        public var isNoNeedServer:Boolean = false;
        public var isShowError:Boolean = false;
        public var isUseATF:Boolean = false;
        public var isEnterNoVoice:Boolean = false;
        public var isEnterSetVoice:Boolean = false;
        public var testData:String = "";
        public var client:int = 0;
        public var platformDownLoadUrl:String = "";
        public var platformDownLoadUrl2:String = "";
        public var showGirlQQ:String = "";
        public var showGirlRechargeAmount:int;
        public var platformMobileVerificUrl:String = "";
        public var platformVipHelpUrl:String = "";
        public var platformVipUpgradeUrl:String = "";
        public var platformLinkUrl:String = "";
        public var QQVipMonthUrl:String = "";
        public var QQVipYearUrl:String = "";
        public var QQBuyUrl:String = "";
        public var isShowQQShop:Boolean = false;
        public var QQVipGuanWangUrl:String = "http://gamevip.qq.com/";
        public var enterType:int;
        public var QQpf:int;
        public var platformProxy:int = 21;
        public static const DefaultPassWord:String = "123456";
        public static const Version:String = "1.0.2.1";
        public static const Flash3DVersion:String = "2.0.0.12";
        public static const Delay:int = 0;
        public static var isPay:Boolean = true;
        private static var _instance:ParamsConst;

        public function ParamsConst()
        {
            if (_instance != null)
            {
                throw new Error(" ParamsConst 单例 ");
            }
            return;
        }// end function

        public function init(param1:Stage) : void
        {
            var _loc_2:Object = null;
            if (param1)
            {
                if (this._isInit == false)
                {
                    _loc_2 = param1.loaderInfo.parameters;
                    write(_loc_2);
                    this.replaceParam();
                    PathConst.mainPath = this.mainPath == null ? ("") : (this.mainPath);
                    this._isInit = true;
                    this.time = new Date(parseFloat(this.time) * 1000);
                    if (this.payUrl == null)
                    {
                        this.payUrl = "";
                    }
                    else
                    {
                        if (this.payUrl.indexOf("#XXHUserName#") > -1)
                        {
                            this.payUrl = this.payUrl.replace("#XXHUserName#", this.username);
                        }
                        if (this.payUrl.indexOf("#XXHServer#") > -1)
                        {
                            this.payUrl = this.payUrl.replace("#XXHServer#", this.server);
                        }
                    }
                    if (this.favoritesUrl.indexOf("#XXHUserName#") > -1)
                    {
                        this.favoritesUrl = this.favoritesUrl.replace("#XXHUserName#", this.username);
                    }
                    switch(this.QQpf)
                    {
                        case 1:
                        {
                            this.enterType = 1;
                            break;
                        }
                        case 10:
                        {
                            this.enterType = 2;
                            break;
                        }
                        default:
                        {
                            this.enterType = 0;
                            break;
                            break;
                        }
                    }
                    ParamsConst.isPay = this.sDocc == 1 ? (true) : (false);
                    PHPSender.isCreateRole = this.newUser == 1;
                    this.setDebugModle(_loc_2);
                }
            }
            else
            {
                this._isInit = false;
                throw new Error("stage == null");
            }
            return;
        }// end function

        private function replaceParam() : void
        {
            var _loc_3:String = null;
            var _loc_4:String = null;
            var _loc_1:* = ObjectParser.getClassVars(this);
            var _loc_2:int = 0;
            while (_loc_2 < _loc_1.length)
            {
                
                _loc_3 = _loc_1[_loc_2];
                if (this[_loc_3] is String)
                {
                    _loc_4 = this[_loc_3] as String;
                    if (_loc_4)
                    {
                        this[_loc_3] = _loc_4.replace(/#XXHUserName#""#XXHUserName#/g, this.username);
                        this[_loc_3] = this[_loc_3].replace(/#XXHServer#""#XXHServer#/g, this.server);
                    }
                }
                _loc_2++;
            }
            return;
        }// end function

        private function setDebugModle(param1:Object) : void
        {
            if (param1.hasOwnProperty("isDebug"))
            {
                if (param1.isDebug == true || param1.isDebug == "true")
                {
                    Global.isDebugModle = true;
                }
                else
                {
                    Global.isDebugModle = false;
                }
            }
            else
            {
                Global.isDebugModle = false;
            }
            if (param1.hasOwnProperty("isSystem"))
            {
                if (param1.isSystem == true || param1.isSystem == "true")
                {
                    Log.isSystem = true;
                }
                else
                {
                    Log.isSystem = false;
                }
            }
            if (param1.hasOwnProperty("flashVersion"))
            {
                this.flashVersion = param1.flashVersion;
            }
            if (param1.hasOwnProperty("isLocalCache"))
            {
                if (param1.isLocalCache == true || param1.isLocalCache == "true")
                {
                    this.isLocalCache = true;
                }
                else
                {
                    this.isLocalCache = false;
                }
            }
            else
            {
                this.isLocalCache = false;
            }
            if (param1.hasOwnProperty("isUIByLevel"))
            {
                if (param1.isUIByLevel == true || param1.isUIByLevel == "true")
                {
                    this.isUIByLevel = true;
                }
                else
                {
                    this.isUIByLevel = false;
                }
            }
            else
            {
                this.isUIByLevel = false;
            }
            if (param1.hasOwnProperty("isAutoEnterGame"))
            {
                if (param1.isAutoEnterGame == true || param1.isAutoEnterGame == "true")
                {
                    this.isAutoEnterGame = true;
                }
                else
                {
                    this.isAutoEnterGame = false;
                }
            }
            else
            {
                this.isAutoEnterGame = false;
            }
            if (param1.hasOwnProperty("isShowError"))
            {
                if (param1.isShowError == true || param1.isShowError == "true")
                {
                    this.isShowError = true;
                }
                else
                {
                    this.isShowError = false;
                }
            }
            else
            {
                this.isShowError = false;
            }
            if (param1.hasOwnProperty("isUseATF"))
            {
                if (param1.isUseATF == true || param1.isUseATF == "true")
                {
                    this.isUseATF = true;
                }
                else
                {
                    this.isUseATF = false;
                }
            }
            else
            {
                this.isUseATF = false;
            }
            if (param1.hasOwnProperty("gameName"))
            {
                this.gameName = param1.gameName;
            }
            else
            {
                this.gameName = null;
            }
            if (param1.hasOwnProperty("isShowQQShop"))
            {
                if (param1.isShowQQShop == true || param1.isShowQQShop == "true")
                {
                    this.isShowQQShop = true;
                }
                else
                {
                    this.isShowQQShop = false;
                }
            }
            else
            {
                this.isShowQQShop = false;
            }
            return;
        }// end function

        public function get isYYPlan() : Boolean
        {
            return this.platformCode == "test" || this.platformCode.indexOf("duowan") > -1;
        }// end function

        public function get isYYFormalPlan() : Boolean
        {
            return this.platformCode == "duowan";
        }// end function

        public function get isMiniCliet() : Boolean
        {
            return this.client == 1;
        }// end function

        public static function get instance() : ParamsConst
        {
            if (_instance == null)
            {
                _instance = new ParamsConst;
            }
            return _instance;
        }// end function

    }
}
